<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="gdufs.stat.service.FwtjQuery" %>
<%@page import="java.util.*" %>
<%@page import="java.text.*" %>
<html>
<head>
<%
ApplicationContext context = WebApplicationContextUtils.getWebApplicationContext(application); 
FwtjQuery fwtjQuery = (FwtjQuery)context.getBean("fwtjQuery");
%>

<%
	DecimalFormat dFormat = new DecimalFormat("##.##%");
	String deptCode = request.getParameter("deptCode");
	String metier = request.getParameter("metier");
	String starttime = request.getParameter("starttime");
	String endtime = request.getParameter("endtime");
	List<Map> deptVisitStatics = new ArrayList<Map>();
	String deptWeekStatics = "";
	if(deptCode != null && !"".equals(deptCode) && !"null".equals(deptCode)){
		deptVisitStatics = fwtjQuery.getDetailByDeptCode(deptCode,metier,starttime,endtime);
		fwtjQuery.getWeekStatics(deptCode);
	}
	
	
	
%>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<script type="text/javascript" src="../FusionCharts/FusionCharts.js"></script>
</head>
<body>
<center>
	<div style="width:90%;">
		
		<!-- 部门人员登录系统统计 -->
		<div style="width: 100%;">
			<div id="bmfwxxContainer">FusionCharts will load here!</div>                   
				<script type="text/javascript">
					var bmfwxxChart = new FusionCharts( "../FusionCharts/Column3D.swf","bmfwxxChartId", "100%", "100%", "0", "1" );  
					bmfwxxChart.setXMLData("<%=deptWeekStatics%>");   
					bmfwxxChart.render("bmfwxxContainer");        
				</script>
			</div>
		</div>

		<!-- 列表统计 -->
		
		<div style="width: 100%;">
			<table cellpadding="0" cellspacing="0" width="100%" border="1">
				<tr>
					<th>姓名</th>
					<th>登录次数</th>
					<th>占部门登录次数百分比</th>
				</tr>
				<%
				for(int i = 0 ; i < deptVisitStatics.size() ; i++){
					Map userStaticsItem = (Map)deptVisitStatics.get(i);
					String userid = (String)userStaticsItem.get("userid");
					String username = (String)userStaticsItem.get("username");
					int visitAccount = (Integer)userStaticsItem.get("visitAccount");
					int percentage = (Integer)userStaticsItem.get("percentage");
				%>
					<tr>
						<td><%=username %></td>
						<td><%=visitAccount %></td>
						<td><%=dFormat.format(percentage) %></td>
					</tr>
				<% 
				}
				%>
			</table>			
		</div>
		
	</div>
</center>
</body>
</html>